<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
    <meta content="text/html " charset="utf-8" http-equiv="content-type"/>
    <meta name="author" content="Haolin,haolinhom@gmail.com"/>
    <title>注册 - 云猫智付</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <!--other-->
    <meta name="description" content="">
    <meta name="keywords" content="云猫智付">
    <meta name="renderer" content="webkit">
    <!--IOS-->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-title" content="云猫智付">
    <!--<meta name="apple-mobile-web-app-status-bar-style" content="white">-->
    <!--<link rel="apple-touch-icon-precomposed" href="static/img/touch/icon-196x196.png">-->
    <!--Android-->
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="theme-color" content="#00a0e9">
    <!--<link rel="icon" sizes="196x196" href="static/img/touch/icon-196x196.png">-->
    <!-- Wechat meta -->
    <meta property="weixin:timeline_title" content="云猫智付">
    <meta property="weixin:chat_title" content="云猫智付">
    <meta property="weixin:description" content="">
    <!--<meta property="weixin:image" content="static/img/touch/icon-180x180.png">-->
    <!--static-->
    <link rel="alternate icon" type="image/png" href="../catpay/img/logo.png">
    <link rel="stylesheet" href="../catpay/css/weui.min.css">
    <link rel="stylesheet" href="../catpay/css/jquery-weui.min.css">
    <link rel="stylesheet" href="../catpay/css/normalize.css">
    <!--<link rel="stylesheet/less" type="text/css" href="../catpay/css/style.less">-->
    <!--<script src="../catpay/js/less.min.js"></script>-->
    <link rel="stylesheet" href="../catpay/css/style.css">

    <!--<script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>-->
</head>
<body>
<header class="app-reg-header">
    <div class="header-text">云猫智付注册页</div>
</header>
<div id="app-reg">

    <div class="row">
        <input id="input-name" class="form-ctrl" type="text" placeholder="请输入您的姓名">
    </div>
    <div class="row">
        <input id="input-phone" class="form-ctrl" type="number" placeholder="请输入您的手机号码">
    </div>
    <div class="row">
        <div class="yz-code-container">
            <div class="yz-code-wrapper">
                <input id="input-code" class="form-ctrl" type="number" placeholder="请输入验证码">
            </div>
            <div class="yz-code-wrapper">
                <button id="btn-get-code" class="btn-main">获取验证码</button>
                <div id="btn-get-code-cover"></div>
            </div>
        </div>
    </div>
    <div class="row">
        <input id="input-pwd" class="form-ctrl" type="password" placeholder="请设置6~16位密码">
    </div>
    <div class="row">
        <div class="recommend-wrapper">推荐人手机号：<span id="r-man"></span></div>
    </div>
    <div class="row">
        <div class="prompt-wrapper">请先注册账号，然后下载APP即可直接登录</div>
    </div>
    <div class="row">
        <button id="btn-reg" class="btn-main">注册</button>
    </div>
    <div class="row">
        <button id="btn-app" class="btn-main">下载APP</button>
    </div>
</div>

<script src="../catpay/js/flexible.js"></script>
<script src="../catpay/js/haolin.js"></script>
<script src="../catpay/js/project.js"></script>
<script src="../catpay/js/md5.js"></script>
<script src="../catpay/js/jquery.js"></script>
<script src="../catpay/js/jquery-weui.min.js"></script>
<!--<script src="https://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>-->
<!--<script src="https://cdn.bootcss.com/jquery-weui/1.2.0/js/jquery-weui.min.js"></script>-->
<script>
    var urlParams = {
        referrerId: getUrlParam("referrerId"),
        inviter: getUrlParam("referrerId"),
        sign: getUrlParam("sign"),
        tzbstr: getUrlParam("tzb")
    };
    // $qs("#r-man").textContent = urlParams.inviter;
    $qs("#r-man").textContent = urlParams.tzbstr;

    var token;
    var regCode;
    //
    // fetch.getToken(urlParams.inviter,urlParams.sign,function (data) {
    //     if(data.code==="0000"){
    //         token = data.result;
    //         fetch.getUserDate(urlParams.referrerId,token,function (data) {
    //             if(data.code==="0000"){
    //                 $qs("#r-man").textContent = data.result.realName+" "+data.result.phone;
    //             }else{
    //                 $.toptip(data.message, 'error');
    //             }
    //
    //         });
    //
    //     }else{
    //         console.log("**** 获取token失败 ****");
    //     }
    // });

    var AppReg = {
        data: {
            check: false
        },
        node: {
            phone: $qs("#input-phone"),
            code: $qs("#input-code"),
            pwd: $qs("#input-pwd"),
            codeCover: $qs("#btn-get-code-cover")
        },
        btn: {
            getCode: $qs("#btn-get-code"),
            reg: $qs("#btn-reg"),
            app: $qs("#btn-app")
        },
        event: function () {
            //获取验证码
            this.btn.getCode.addEventListener("click", function (event) {
                event.preventDefault();
                //验证
                var phoneNum = $qs("#input-phone").value;
                if (phoneNum === "") {
                    $.alert("请输入手机号");
                    return;
                }
                if (!phoneVerify(Number(phoneNum))) {
                    $.alert("请输入正确的手机号");
                    return;
                }
                if (!AppReg.data.check) {
                    var tag = event.target;
                    //发送
                    fetch.sendCode(phoneNum, function (data) {
                        if (data.code === "0000") {
                            regCode = data.result;
                            $.toptip('验证码发送成功', 'success');
                        } else {
                            $.toptip('验证码发送失败', 'error');
                        }
                    });
                    //倒计时
                    AppReg.data.check = true;
                    AppReg.node.codeCover.style.display = "block";
                    for (var i = 0; i < 61; i++) {
                        (function (arg) {
                            setTimeout(function () {
                                tag.textContent = 60 - arg + "秒";
                                if (arg === 60) {
                                    tag.textContent = "获取验证码";
                                    AppReg.data.check = false;
                                    AppReg.node.codeCover.style.display = "none";
                                }
                            }, arg * 996);
                        })(i);
                    }
                }
            }, false);
            //注册
            this.btn.reg.addEventListener("click", function (event) {
                event.preventDefault();
                var name = $qs("#input-name").value;
                var phoneNum = $qs("#input-phone").value;
                var coedNum = $qs("#input-code").value;
                var pwdStr = $qs("#input-pwd").value;
                if (name === "") {
                    $.alert("请输入姓名");
                    return;
                }
                if (phoneNum === "") {
                    $.alert("请输入手机号");
                    return;
                }
                if (!phoneVerify(Number(phoneNum))) {
                    $.alert("请输入正确的手机号");
                    return;
                }
                if (coedNum === "") {
                    $.alert("请输入验证码");
                    return;
                }
           
                if (pwdStr === "") {
                    $.alert("请输入密码");
                    return;
                }
                fetch.reg({
                    nickName: name,
                    phone: phoneNum,
                    passWord: hex_md5(pwdStr),
                    code:coedNum,
                    recommonNumber: urlParams.tzbstr,
                    // token:token
                }, function (data) {
                    if (data.code === "0000") {
                        $.modal({
                            title: "恭喜您，您已注册成功",
                            text: "请马上下载云猫智付APP体验",
                            buttons: [
                                {
                                    text: "前往下载", onClick: function () {
                                        window.open("../download/index.html", "_self");
                                    }
                                }
                            ]
                        });
                    } else {
                        $.toptip(data.message, 'error');
                    }
                });
            }, false);
            //下载
            this.btn.app.addEventListener("click", function (event) {
                event.preventDefault();
                window.open("../download/index.html", "_self");
            }, false);
        }
    };

    AppReg.event();
</script>
</body>

</html>